precision mediump float;
uniform sampler2D u_texture;
uniform vec3 Camera_Position; 


varying vec2 v_uv;
varying vec3 v_currentVertexPos;
varying vec3 v_normal;
void main()
{
	//
	vec3 light_position=vec3(1.0,1.0, 1.0);
	
	 vec4 light_ambient=vec4(0.3, 0.3, 0.3, 1.0);
	 
	 vec4 light_diffuse=vec4(0.9, 0.9, 0.9, 1.0);
	 
	 vec4 light_specular=vec4(1.0);
	 
	float light_constantAttenuation=0.05; 
	
    float light_linearAttenuation=0.05; 
    float light_quadraticAttenuation=0.05; 
    
     float Material_shininess=64.0; 
    
   
	//Get light vector L of current vertex 
 
   
   //Get distance between of Light and vertex 
   float distance = length(light_position-v_currentVertexPos); 
   
   vec3 currentlightVector = normalize(light_position -v_currentVertexPos); 
   
   float NDotL = max( 0.0 , dot(v_normal, currentlightVector));
   
   //Get Attenuation of light (strength of light) 
   float attenuation =  1.0/(light_constantAttenuation +light_linearAttenuation * distance + light_quadraticAttenuation * distance * distance);
    
   vec4 v_diffuse = light_diffuse * NDotL* attenuation;
   
   vec4 v_ambient = light_ambient;
   
   vec3 eyeVector = normalize(Camera_Position-v_currentVertexPos); 
   
   vec3 reflectVector = normalize(reflect(currentlightVector,v_normal)); 
   
   float RdotE = max(0.0, dot(eyeVector, reflectVector)); 
   
   float reflectPower = pow(RdotE, Material_shininess); 
   
   vec4 v_specular = clamp(light_specular * reflectPower, 0.0, 1.0) *  attenuation;
   
   vec4 fragmentColor = vec4(1.0, 0.0, 0.0, 1.0);;
    
   gl_FragColor = fragmentColor * (v_diffuse + v_ambient+v_specular);
   
}
